﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using SelfService.Model.Models;


namespace SelfService.ViewModel.SysRoomVMs
{
    public partial class SysRoomListVM : BasePagedListVM<SysRoom_View, SysRoomSearcher>
    {

        protected override IEnumerable<IGridColumn<SysRoom_View>> InitGridHeader()
        {
            return new List<GridColumn<SysRoom_View>>{
                this.MakeGridHeader(x => x.HisId),
                this.MakeGridHeader(x => x.Code),
                this.MakeGridHeader(x => x.Name),
                this.MakeGridHeader(x => x.DepartmentId),
                this.MakeGridHeader(x => x.DepartmentCode),
                this.MakeGridHeader(x => x.DepartmentName),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysRoom_View> GetSearchQuery()
        {
            var query = DC.Set<SysRoom>()
                .CheckContain(Searcher.HisId, x=>x.HisId)
                .CheckContain(Searcher.Code, x=>x.Code)
                .CheckContain(Searcher.Name, x=>x.Name)
                .CheckContain(Searcher.DepartmentId, x=>x.DepartmentId)
                .CheckContain(Searcher.DepartmentCode, x=>x.DepartmentCode)
                .CheckContain(Searcher.DepartmentName, x=>x.DepartmentName)
                .Select(x => new SysRoom_View
                {
				    ID = x.ID,
                    HisId = x.HisId,
                    Code = x.Code,
                    Name = x.Name,
                    DepartmentId = x.DepartmentId,
                    DepartmentCode = x.DepartmentCode,
                    DepartmentName = x.DepartmentName,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class SysRoom_View : SysRoom{

    }
}
